home *** CD-ROM | disk | FTP | other *** search
/ Chip 2006 December / chip-cd_2006_12.zip / 12 / Pakiet internetowy / Stacje TV i radiowe (odsluchiwanie i rippowanie) / Streamripper winamp5 1.61.27 / srwa5-1.61.27.exe / $1 / fetch_external_metadata.pl < prev    next >
Perl Script  |  2005-11-11  |  1KB  |  42 lines

  1. #! /usr/bin/perl
  2. ###########################################################################
  3. # This is an example script that sends external metadata to streamripper.
  4. # It implements an external program that:
  5. #   1) Fetches a web page
  6. #   2) Searches the web page for the artist and title information
  7. #   3) Sends the information to streamripper
  8. # To invoke the script, do this:
  9. #    streamripper URL -E "perl fetch_external_metadata.pl META_URL"
  10. #
  11. # This assumes that META_URL is the URL with the artist/title information
  12. # You will need perl and LWP::Simple installed to run this script. 
  13. # On unix, you install LWP::Simple as root, like this:
  14. #    perl -MCPAN -e 'install LWP::Simple';
  15. # On windows, LWP::Simple is included in the ActiveState perl distribution.
  16. #
  17. # This script is in the public domain. You are free to use, modify and 
  18. # redistribute without restrictions.
  19. ###########################################################################
  20.  
  21. use LWP::Simple;
  22.  
  23. if ($#ARGV != 0) {
  24.     die "Usage: fetch_external_metadata.pl URL\n";
  25. }
  26. $url = $ARGV[0];
  27.  
  28. while (1) {
  29.     my $content = get $url;
  30.  
  31.     if ($content =~ m/title="(.*)" artist="(.*)"/) {
  32.     $title = "TITLE=$1\n";
  33.     $artist = "ARTIST=$2\n";
  34.     $end_of_record = ".\n";
  35.     $meta_data = $title . $artist . $end_of_record;
  36.     syswrite (STDOUT, $meta_data, length($meta_data));
  37.     }
  38.     sleep (10);
  39. }
  40.